package com.abc.scholarship.exception;

import com.abc.scholarship.common.enums.CommonErrorEnum;
import lombok.Data;

/**
 * 自定义异常
 * @Author LiJunXi
 * @Date 2024-03-01 14:37
 */
@Data
public class BusinessException extends RuntimeException {

    protected Integer errorCode;

    protected String errorMsg;

    public BusinessException(String msg){
        super(msg);
        this.errorMsg = msg;
        this.errorCode = CommonErrorEnum.BUSINESS_ERROR.getCode();
    }

    public BusinessException(Integer code, String msg){
        super(msg);
        this.errorMsg = msg;
        this.errorCode = code;
    }

    public BusinessException(CommonErrorEnum commonErrorEnum){
        super(commonErrorEnum.getDesc());
        this.errorMsg = commonErrorEnum.getDesc();
        this.errorCode = commonErrorEnum.getCode();
    }

}
